<?php
        
        abstract class BalloonStyleClass {
                    const Success       =   'download-box';
                    const Error         =   'error-box';
                    const Warning       =   'notification-box';
                    const Info          =   'info-box';
        }


        class BalloonControl extends QPanel {
            
            //protected $blnDisplay = false;

            private $actShow;
            private $actHide;
            
            public $strImage;
            public $strTitle;
            public $strMessage;
            
            public $btnClose;
            
            
            public function __construct($objParentObject, $strControlId = null) {
                    parent::__construct($objParentObject, $strControlId);
                    
                    $this->DisplayStyle = QDisplayStyle::None;
                    
                    $this->Template = __SITE_VIEW_SHARED__ . '/balloon.tpl.php';

                    $this->actShow = new QJQShowAction($this, 'slow');
                    $this->actHide = new QJQHideAction($this, 'slow');
                    
                    $this->btnClose = new QButton($this);
                    $this->btnClose->Text = "×";
                    $this->btnClose->CssClass = 'close';
                    $this->btnClose->AddAction(new QClickEvent(), $this->actHide);
            }

            function Success($strTitle, $strMessage, $blnShow = true) {
                $this->CssClass = BalloonStyleClass::Success;
                $this->Ballon($strTitle, $strMessage, '../../content/images/icon-download.png', $blnShow);
            }

            function Warning($strTitle, $strMessage, $blnShow = true) {
                $this->CssClass = BalloonStyleClass::Warning;
                $this->Ballon($strTitle, $strMessage, '../../content/images/icon-note.png', $blnShow);
            }

            function Information($strTitle, $strMessage, $blnShow = true) {
                $this->CssClass = BalloonStyleClass::Information;
                $this->Ballon($strTitle, $strMessage, '../../content/images/icon-info.png', $blnShow);
            }

            function Error($strTitle, $strMessage, $blnShow = true) {
                $this->CssClass = BalloonStyleClass::Error;
                $this->Ballon($strTitle, $strMessage, '../../content/images/icon-error.png', $blnShow);
            }
            
            private function Ballon($strTitle, $strMessage, $strImage = null, $blnShow = true)
            {
                $this->strImage = $strImage;
                $this->strTitle = $strTitle;
                $this->strMessage = $strMessage;
                if ($blnShow)
                    $this->ShowHide();
            }
            
            private function Show() {
                QApplication::ExecuteJavaScript($this->actShow->RenderScript($this));
            }
            
            private function Hide() {
                QApplication::ExecuteJavaScript($this->actHide->RenderScript($this));
            }
           
            private function ShowHide() {
                $this->Hide(); $this->Show();
            }
        }
?>